package org.doubango.FrCall.Screens;

import org.doubango.FrCall.Engine;
import org.doubango.FrCall.R;
import org.doubango.FrCall.Services.IScreenService;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ScreenSearchFriend extends BaseScreen {
	
	private static String TAG = ScreenChatSip.class.getCanonicalName();
	private final IScreenService mScreenService;
	
	private Button backToFriendViewFromSearchFriend;
	private Button searchFriendById;
	private Button searchFriendByName;
	private Button searchFriendByRule;
	private Button searchFriendNearby;
	
	public ScreenSearchFriend() {
		super(SCREEN_TYPE.SEARCH_FRIEND, TAG);
		mScreenService = ((Engine)Engine.getInstance()).getScreenService();
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.screen_search_friend);
		backToFriendViewFromSearchFriend = (Button) findViewById(R.id.back_to_friend_view_from_search_friend);
		searchFriendById = (Button) findViewById(R.id.search_friend_by_id);
		searchFriendByName = (Button) findViewById(R.id.search_friend_by_name);
		searchFriendByRule = (Button) findViewById(R.id.search_friend_by_rule);
		searchFriendNearby = (Button) findViewById(R.id.search_friend_nearby);
		
		SearchFriendButtonListener searchFriendButtonListener = new SearchFriendButtonListener();
		backToFriendViewFromSearchFriend.setOnClickListener(searchFriendButtonListener);
		searchFriendById.setOnClickListener(searchFriendButtonListener);
		searchFriendByName.setOnClickListener(searchFriendButtonListener);
		searchFriendByRule.setOnClickListener(searchFriendButtonListener);
		searchFriendNearby.setOnClickListener(searchFriendButtonListener);
	}
	private class SearchFriendButtonListener implements OnClickListener{
		@Override
		public void onClick(View v) {
			if(v == backToFriendViewFromSearchFriend){
				mScreenService.show(ScreenFriendList.class);
			}else if(v == searchFriendById){
				ScreenSearchedFriendInfo.i = 1;
				mScreenService.show(ScreenSearchFriendById.class);
			}else if(v == searchFriendByName){
				ScreenSearchedFriendInfo.i = 2;
				mScreenService.show(ScreenSearchFriendByNickname.class);
			}else if(v == searchFriendByRule){
				ScreenSearchedFriendInfo.i = 3;
				mScreenService.show(ScreenSearchFriendByRule.class);
			}else if(v == searchFriendNearby){
				ScreenSearchedFriendInfo.i = 4;
				mScreenService.show(ScreenSearchFriendNearby.class);
			}
		}
		
	}

}
